
let id = getId()
let review = null
// 获取网站配置
$.ajax({
  type: 'get',
  url: '/settings',
  success: function(response) {
    review = response.review
  }
})
//  创建评论
$('.commentBtn').on('click', function() {
  var state
 let content = $('.commentInput').val()
  if (review) {
    // 需要人工审核
    state = 0
  }else {
    state = 1
  }
  $.ajax({
    type: 'post',
    url: '/comments',
    data: {
      content: content,
      post: id,
      state: state
    },
    success: function(response) {
      location.reload()
    }
  })

})
// 获取id文章信息
$.ajax({
  type: 'get',
  url: '/posts/'+ id,
  success: function(response) {
    let html = template('detailTpl', response)
    $('.commentDetail').html(html)
  }
})